package com.Servlet;

import com.Service.Impl.Okayapi_goodsServiceImpl;
import com.Service.Okayapi_goodsService;
import com.entity.Okayapi_goods;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author: 冷俊杰
 * @Description: 根据ID删除商品
 * @DateTime: 2022/6/21 14:05
 **/
@WebServlet(name = "/DeleteGoods",value = "/DeleteGoods")
public class DeleteGoods extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Okayapi_goodsService service=new Okayapi_goodsServiceImpl();
        Integer id= Integer.parseInt(request.getParameter("id"));
        int i = service.DeleteGoods(new Okayapi_goods(id));
        System.out.println("结果"+i);
        PrintWriter out = response.getWriter();
        out.print("y");
        request.getRequestDispatcher("./CommodityManage.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
